package org.github.manx98.jlibhac.tools.fssystem.ncautils;

import lombok.ToString;
import org.github.manx98.jlibhac.common.math.Uint32;
import org.github.manx98.jlibhac.common.math.Uint64;
import org.github.manx98.jlibhac.common.reflect.StructureMap;
import org.github.manx98.jlibhac.fssystem.DistributionType;
import org.github.manx98.jlibhac.fssystem.NcaContentType;

/**
 * @author Manx98
 * @version 1.0
 * @since 2022/10/3 15:31
 */
@ToString
public class NcaHeaderStruct {
    public static final int RightsIdOffset = 0x230;
    public static final int RightsIdSize = 0x10;
    public static final int SectionEntriesOffset = 0x240;
    public static final int FsHeaderHashOffset = 0x280;
    public static final int FsHeaderHashSize = 0x20;
    public static final int KeyAreaOffset = 0x300;
    public static final int KeyAreaSize = 0x100;
    public static final int FsHeadersOffset = 0x400;
    public static final int FsHeaderSize = 0x200;

    @StructureMap(offset = 0x000)
    public byte Signature1;
    @StructureMap(offset = 0x100)
    public byte Signature2;
    @StructureMap(offset = 0x200)
    public Uint32 Magic;
    @StructureMap(offset = 0x204)
    public DistributionType DistributionType;
    @StructureMap(offset = 0x205)
    public NcaContentType ContentType;
    @StructureMap(offset = 0x206)
    public byte KeyGeneration1;
    @StructureMap(offset = 0x207)
    public byte KeyAreaKeyIndex;
    @StructureMap(offset = 0x208)
    public long NcaSize;
    @StructureMap(offset = 0x210)
    public Uint64 TitleId;
    @StructureMap(offset = 0x218)
    public int ContentIndex;
    @StructureMap(offset = 0x21C)
    public Uint32 SdkVersion;
    @StructureMap(offset = 0x220)
    public byte KeyGeneration2;
    @StructureMap(offset = NcaHeaderStruct.RightsIdOffset, length = RightsIdSize)
    public byte[] RightsId;
    @StructureMap(offset = 0x140)
    public Uint64 upperCounter;
}
